<template>
	<view>
	<u--form :model="indetlist" ref="addaddressform"  class="demo-ruleForm" style="margin-top:48px;">
			<u-row>
				<u-col span=3>
						<p style="float: left; line-height: 40px;margin-left: 10px;">头像：</p>
				</u-col>
				<u-col span=9> 
						   <u-image @click="headclick"  class="u-avatar-demo"  width="200rpx" height="200rpx" :src="userAvatar" shape="circle" mode="aspectFill"  ></u-image>	   

				</u-col>
			</u-row>
			<u-row>
				<u-col span=3>
						<p style="float: left; line-height: 40px;margin-left: 10px;">名称：</p>
				</u-col>
				<u-col span=9> 
				<u--input
				style="width: 250px;  margin-top: 15px; "
				placeholder="请输入姓名"
				border="surround"
				v-model="indetlist.userName"
				></u--input>
				</u-col>
			</u-row>
			<u-row>
				<u-col span=3>
					<p style="float: left; line-height: 40px;margin-left: 10px;">邮箱号：</p>
				</u-col>
				<u-col span=9> 
				<u--input
				style="width: 250px; margin-top: 15px; "
				placeholder="请输入邮箱"
				border="surround"
				v-model="indetlist.userEmail"
				></u--input>
				</u-col>
			</u-row>
			 <u-button class ="que" type="primary"  shape="circle" :plain="true"  @click="addindetill('addaddressform')" style="width: 150px;margin-top: 50px; height: 45px;">修改个人信息</u-button>
	</u--form>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				userAvatar:'',
				 jsfileList1:[],
					loginId:'',
					id:'',
				indetlist:{
					id:'',
					userId:'',
					userName:'',
					userEmail:'',
					userAvatar:'',
					file:null,
				},
			}
		},
		mounted () {
			var userId = uni.getStorageSync("loginId")
			this.userAvatar = 'http://101.43.223.224:8765/image/getImageById?id='+uni.getStorageSync("userAvatar")
			if(userId){
			    this.id = userId
			} 
		  this.indetile() //订单单查
		}, 
		methods: {
				headclick(){
						var that = this
						uni.chooseImage({
							count:1,
							success(res){
								console.log(res)
								that.userAvatar=res.tempFilePaths[0]
								that.indetlist.file = res.tempFiles[0]
								
							}
						})			
					},
			indetile(){
				var that = this
				uni.request({
						url: "http://"+that.$host+":"+that.$port+"/clientuser/clientUserId", 
							data:{
							id:that.id,
							},
						method: 'GET',
						dataType: 'json',
						success: (res) => {
						that.indetlist = res.data.obj
						console.log(that.indetlist.lenght)
							},                  	
						});
						
						
			
			},
			addindetill(){
				const that = this;
				var formdata = new FormData()
				for(var a in this.indetlist){
					if(this.indetlist[a]){
						formdata.set(a, this.indetlist[a])
					}
				}
				// formdata.set('id',this.id)
				// formdata.set('userName', this.indetlist.userName)
				// formdata.set('userEmail', this.indetlist.userEmail)
				if(this.indetlist.file){
					formdata.set('file',this.indetlist.file,this.indetlist.file.fileName)
				}
				this.$axios.post('http://'+that.$host+':'+that.$port+'/clientuser/clientUserUpdate',formdata).then(res => {
					if(res.data.flag){
					uni.showToast({ //添加成功提示
							  icon: 'success',
							  	 title: '修改成功',
							 // 显示时长时间为1000秒
							 duration: 1000
							})
							
							setTimeout(function () { 
								uni.navigateBack({data:1})// 定时任务
							},1000) 
						}
				})
				// uni.request({
				// 		axios: "http://localhost:8088/clientuser/clientUserUpdate",          
				// 		method: 'POST',
				// 		data: this.indetlist,
				// 		dataType: 'json',
				// 		success: (res) => {
						// 	if(res.data.flag){
						// uni.showToast({ //添加成功提示
						// 		 icon: 'success',
						// 		 title: '修改成功',
						// 		 // 显示时长时间为1000秒
						// 		 duration: 1000
						// 		})
						// 		this.timer = setInterval(function () { 
						// 			uni.navigateBack({data:1})// 定时任务
						// 		},1000) 
						// 	}
				// 		},
				// 		});
			},
		}
	}
</script>

<style>

</style>
